package com.sh.sales.happysales.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.Window;

import com.sh.polymedicine.happysale.service.envelop.HappySaleManager;
import com.sh.sales.happysales.R;
import com.sh.sales.happysales.app.AppManager;
import com.sh.sales.happysales.app.utils.StatusBarCompat;
import com.sh.sales.happysales.imgutil.LoadImageManager;
import com.sh.sales.happysales.service.LoginObserable;

/**
 * Created by zhouyucheng on 2017/9/14.
 */

public class BaseActivity extends FragmentActivity {
    protected HappySaleManager mHappySaleManager;
    protected LoadImageManager mLoadImageManager;
    protected AppManager mAppManager;
    protected LoginObserable mLoginObserable;
  //  private OnBooleanListener onPermissionListener;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        StatusBarCompat.compat(this, getResources().getColor(R.color.standardred));
        if (mHappySaleManager == null) {
            mHappySaleManager = HappySaleManager.getInstence();
        }
        if (mLoadImageManager == null) {
            mLoadImageManager = LoadImageManager.getInstance(this);
        }
        if (mAppManager == null) {
            mAppManager = AppManager.getAppManager();
        }
        if (mLoginObserable == null) {
            mLoginObserable = LoginObserable.getInstance();
        }
    }

//    public void permissionRequests(Activity activity, String permission, OnBooleanListener onBooleanListener) {
//        onPermissionListener = onBooleanListener;
//        if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {
//            if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.READ_CONTACTS)) {
//                onPermissionListener.onClick(true);
//            } else {
//                ActivityCompat.requestPermissions(activity, new String[]{permission}, 1);
//            }
//        } else {
//
//            if (onPermissionListener != null) {
//                onPermissionListener.onClick(true);
//            }
//        }
//    }
//
//    @Override
//    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
//        if (requestCode == 1) {
//            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                if (onPermissionListener != null) {
//                    onPermissionListener.onClick(true);
//                }
//            } else {
//                if (onPermissionListener != null) {
//                    onPermissionListener.onClick(false);
//                }
//            }
//            return;
//        }
//        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//    }
//    public interface OnBooleanListener {
//        void onClick(boolean bln);
//    }
}
